// let n: number;
// n = 8;
let n: number = 8.8;
// n = true;
console.log(n);
let s: string = "hello"; //字符串
console.log(s);
let flag: boolean = false;
console.log(flag);
let age: undefined;
console.log(age);
let p: null = null;
console.log(p);
let x: symbol = Symbol("Hello");
console.log(x);

let stu: Date = new Date();
console.log(stu);

// 数组类型: string 是 String 的别名
let arr: number[] = [12, 34, 56, 67, 89];
console.log(arr);
let arr3: Array<String> = ["admin", "123", "admin3"];
console.log(arr3);

// 数组元素可以是number和string类型
let arr2: (number | string | boolean)[] = [12, 34, "admin", 13, true];
console.log(arr2);
let arr4: number | string[] = 12;
arr4 = ["23", "45", "admin"];
console.log(arr4);

//以上js类型

// 复杂类型|联合类型
type customType = (number | string)[];
let arr5: customType = [12, 34, 45, "admin", "123", "admin3"];
console.log(arr5);

// 自定义对象类型
class Person {
  name: string;
  age: number;
  constructor(name: string, age: number) {
    this.name = name;
    this.age = age;
  }
}
let person: Person = new Person("张三", 10);
console.log(person);
